<template>
  <div>
    <Navbar :navtitle="titles"></Navbar>
     <input type="text"  placeholder="请输入4~25个字符"  v-model="namecick"> 
     <div class="save" @click="postnick()">保存</div>
  </div>
</template>

<script>
import Navbar from '@/components/Navbar'
import qs from 'qs'
export default {
     components:{
        Navbar
    },
data(){
  return{
    titles:"修改昵称",
    namecick:''
  }
},
     methods:{
              postnick(){
                  this.$http
        .post(
          "https://web-gateway.newbeescm.com/b2b-app-web/user/nickUpdate",
        qs.stringify(  {
            nickName:this.namecick,
            userId:this.$store.state.userInfo.id
          }),
          {
            headers: {
              token: this.$store.state.token,
              userId: this.$store.state.userInfo.id
            }
          }
        ).then(res => {
           alert('修改成功')
           this.$router.push({path:"/one"})
          console.log(res);
        })
              }
     },
     watch:{
          namecick:function(val){
              //  if(!/^\d*\.?\d{0,2}$/.text(val)){
              //    return ""
              //  }
     //    console.log(!/^\d*\.?\d{0,2}$/.test(val))
            //     if(!val) return
        if(!/^.{3,20}$/.test(val)){
          return ''
        }
          }  
     },
     mounted(){

     }
}

</script>
<style lang="scss" scoped>
.save{
  color: #DD3333 ;
  font-size: 0.14rem;
  position: absolute;
  top: 0.13rem;
  right: 0.135rem;
  z-index: 22222;
}
input{
  height: 0.44rem;
 // width: 100%;
  outline: none;
  border: 1px solid transparent;
  margin-top: 0.06rem;
  padding-left: 0.15rem;
}
</style>
